<?php
namespace Home\Controller;
use Think\Controller;
class IndexController extends Controller {
    public function index(){
        $this->display('index');
    }
	
	public function userLogin(){
		if(empty($_POST)){
			$this->display('Login');
		 return true;	
		}
		$userObj= new \Home\Model\UserModel();
		$loginStatus=$userObj->userLogin($_POST);
		if($loginStatus){
			session('email',$loginStatus['email']);
			session('id',$loginStatus['id']);
			session('loginStatus',true);
			$this->redirect('Manager/index','',0,'登陆成功');
		}
		
		
    }
	
	public function userRegister(){
		if(empty($_POST)){
			$this->display('register');
			return true;	
		}
		$userObj= new \Home\Model\UserModel();
		$status=$userObj->userRegister($_POST);
		var_dump($status);
		if($status== false){
			$this->redirect('userRegister','',1,'注册失败'.$userObj->lastErrorMessage);
			return false;
		}
		$this->redirect('userLogin','',1,'注册成功');
		
	}
}